#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include "CustomListView.h"

#include <QLineEdit>
#include <QWidget>
#include <QVBoxLayout>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWidget;
}
QT_END_NAMESPACE

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    MainWidget(QWidget *parent = nullptr) : QWidget(parent) {
        auto *layout = new QVBoxLayout(this);

        lineEdit = new QLineEdit(this);
        customListView = new CustomListView(this);

        layout->addWidget(lineEdit);
        layout->addWidget(customListView);

        connect(lineEdit, &QLineEdit::textChanged, customListView, &CustomListView::filterDataSlot);

        // 设置初始数据
        QStringList initialData = {"Apple", "Banana", "Cherry", "Date", "Elderberry"};
        customListView->setData(initialData);
    }

private:
    QLineEdit *lineEdit;
    CustomListView *customListView;
};
#endif // MAINWIDGET_H
